---
import MainHead from '../components/MainHead.astro';
import Footer from '../components/Footer.astro';
import Nav from '../components/Nav.astro';
import PortfolioPreview from '../components/PortfolioPreview.astro';
import type { Project } from '../types';

const projects = (await Astro.glob<Project>('./project/**/*.md'))
	.filter(({ frontmatter }) => !!frontmatter.publishDate)
	.sort(
		(a, b) =>
			new Date(b.frontmatter.publishDate).valueOf() - new Date(a.frontmatter.publishDate).valueOf()
	);
---

<html lang="en">
	<head>
		<MainHead
			title="All Projects | Jeanine White"
			description="Learn about Jeanine White's most recent projects"
		/>
		<style>
			.grid {
				display: grid;
				grid-gap: 3rem;
			}
			.title {
				margin-top: 2rem;
				margin-bottom: 2rem;
			}
		</style>
	</head>
	<body>
		<Nav />
		<div class="wrapper">
			<h1 class="title">All Projects</h1>
			<div class="grid">
				{projects.map((project) => <PortfolioPreview project={project} />)}
			</div>
		</div>
		<Footer />
	</body>
</html>
